<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class ResidentController extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		$this->load->helper('url');
	}
	
	function loadAddResidentView()
	{
		$this->load->view('AddResidentView');
	}
	
	function addResident()
	{
		$this->load->model('Resident_model');
		$this->Resident_model->add_resident($_POST);
		redirect('adminPageController');
	}
	
	function loadResidentToEditView()
	{
		$this->load->view('ResidentToEditView');
	}
	
	function loadEditResidentView()
	{
		$this->load->model('Resident_model');
		$sql['data'] = $this->Resident_model->check_resident($_POST);
		$this->load->view('EditResidentView',$sql);
	}
	
	function editResident()
	{
		$this->load->model('Resident_model');
		$this->Resident_model->edit_resident($_POST);
		redirect('adminPageController');
	}
	
	function loadResidentToSearchView()
	{
		$this->load->view('ResidentToSearchView');
	}
	
	function loadSearchResidentView()
	{
		$this->load->model('Resident_model');
		$sql['data'] = $this->Resident_model->check_resident($_POST);
		$this->load->view('SearchResidentView',$sql);
	}
	
	function loadDeleteResidentView()
	{
		$this->load->model('Resident_model');
		$sql['data'] = $this->Resident_model->get_all_residents($_POST);
		$this->load->view('DeleteResidentView',$sql);
	}
	
	function deleteResident()
	{
		$this->load->model('Resident_model');
		$sql['data'] = $this->Resident_model->delete_resident($_POST);
		redirect('residentController/loadDeleteResidentView');
	}
	
	function loadDeleteAllResidentsView()
	{
		$this->load->model('Resident_model');
		$sql['data'] = $this->Resident_model->get_all_residents($_POST);
		$this->load->view('DeleteAllResidentsView',$sql);
	}
	
	function deleteAllResidents()
	{
		$this->load->model('Resident_model');
		$this->Resident_model->delete_all_residents($_POST);
		redirect('adminPageController');
	}
	
}

/* End of file residentController.php */
/* Location: ./application/controllers/residentController.php */
?>